Fix using a non-tuple sequence for multidimensional indexing that wil…#8732
Fix using a non-tuple sequence for multidimensional indexing that wil…#8732aarpon wants to merge 3 commits intoProject-MONAI:devfrom
Conversation
…l result in error in pytorch 2.9.
📝 WalkthroughWalkthroughThis PR updates monai/inferers/utils.py to normalize tensor indexing across sliding-window inference by converting list-based indices to tuples. Changes apply to batched and non-batched paths when gathering window data and conditions, updating the sliding-window device buffer and final outputs, and when accumulating patch contributions in _compute_coords. No public API signatures are changed. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @aarpon thanks for these fixes, I know tuple indices are needed in places more strictly than in the past. Would it make sense to use |
Fix using a non-tuple sequence for multidimensional indexing that will result in error in pytorch 2.9.
Fixes # .
Description
The
SlidingWindowInferercomplains that from PyTorch 2.9, using non-tuple sequences to slice into Tensors will result in an error (or, worse, misbehave). This patch targets all places inmonai/inferers/utils.pywhere indexing may happen with lists or other types of sequences.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.